//
//  DDGScollShotBottomCyclePagerCell.swift
//  TYCyclePagerViewDemo_swift
//
//  Created by tany on 2017/7/20.
//  Copyright © 2017年 tany. All rights reserved.
//

import UIKit

class DDGScollShotBottomCyclePagerCell: UICollectionViewCell {
    
    lazy var label = UILabel()
    lazy var bgImageView : UIImageView = UIImageView()
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.addTextLabel()
    }
    
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        self.addTextLabel()
    }
    
    func addTextLabel() {
        bgImageView = UIImageView(frame: CGRect(x: 0, y:0, width: self.frame.size.width, height: self.frame.size.height))
        self.addSubview(bgImageView)
        bgImageView.layer.masksToBounds = true
        // 设置圆角大小
        bgImageView.layer.cornerRadius = 3.0
        //设置边框的颜色
        bgImageView.layer.borderColor = (UIColor.init(white: 0.8, alpha: 1.0).cgColor)
        //设置边框的粗细
        bgImageView.layer.borderWidth = 1.0

        self.label.textColor = UIColor.white
        self.label.textAlignment = NSTextAlignment.center
        self.label.font = UIFont.systemFont(ofSize: 18)
        self.addSubview(self.label)
        
//        //监听版式通知
//        _ = NotificationCenter.default.rx
//            .notification(Notification.Name(rawValue: "DDGScollViewShotDidSelectedItemImageNotification"))
//            .takeUntil(self.rx.deallocated) //页面销毁自动移除通知监听
//            .subscribe(onNext: { [weak self] notification in    //获取通知数据
//                let userInfo = notification.userInfo as! [String: AnyObject]
//                let didSelectIndex = userInfo["didSelectIndex"] as! Int
//                if self?.bgImageView.tag == didSelectIndex {
//                    self?.bgImageView.layer.borderColor = (UIColor(red:0.38, green:0.66, blue:0.87, alpha:1.00).cgColor)
//                }else{
//                    self?.bgImageView.layer.borderColor = (UIColor.init(white: 0.8, alpha: 1.0).cgColor)
//                }
//            })
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        self.label.frame = self.bounds
        bgImageView.frame = self.bounds
    }
}
